package SwingView.Assignment;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JOptionPane;

import JDBC.InstructorAssignmentActivities;
import SwingController.CmsPresenter;
import SwingModel.CmsAssignment;
import SwingModel.CmsUser;
import SwingView.CmsMainView;

public class ALAssignmentDelete implements ActionListener{

	private CmsAssignment asgm;

	public ALAssignmentDelete (CmsAssignment asgm){
		this.asgm = asgm;
	}
	
	@Override
	public void actionPerformed(ActionEvent e) {
		CmsUser user = CmsPresenter.user;
		CmsMainView mainView = CmsPresenter.mainView;
		
		int returnVal = JOptionPane.showConfirmDialog(CmsPresenter.mainView, 
				"Do you want to delete this Assignment:\n" + asgm.getAsgmTitle() + "\n");

		if(returnVal == JOptionPane.YES_OPTION){
			InstructorAssignmentActivities.deleteAssignment(asgm.getAsgmID());
			mainView.displayAssignmentInstructorPage(InstructorAssignmentActivities.getListOfAssignments(CmsPresenter.user.getSelectedCourse().getCourseID()));
	
		}
	}
}
